package com.example.demo.rocketmq.listener;

import com.example.demo.rocketmq.consumer.service.CommonConsumerService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;

import java.util.List;

@RocketMQMessageListener(consumerGroup = "", topic = "")
public class MqConsumerListener implements RocketMQListener {

    final
    List<CommonConsumerService> commonConsumerServices;

    public MqConsumerListener(List<CommonConsumerService> commonConsumerServices) {
        this.commonConsumerServices = commonConsumerServices;
    }

    @Override
    public void onMessage(Object o) {
        commonConsumerServices.forEach(commonConsumerService -> commonConsumerService.send(o));
    }
}
